import { Person } from "~/api/public";

export default function personFn() {
    Person()
        .then(result => {
            let {
                banner,
                version,
                saas,
                shopUser,
                user,
                worker,
                saasConfig
            } = result;

            //平台处理
            if (Object.keys(saas).length) {
                localStorage.setItem("logo", saas.logo);
                localStorage.setItem("slogan", saas.slogan);
                localStorage.setItem("name", saas.name);
                if(saas.miniprogramImg){
                    localStorage.setItem('platform','weapp')
                }else{
                    localStorage.setItem('platform','h5')
                }
            }
            if (Object.keys(user).length) {
                localStorage.setItem("user", JSON.stringify(user));
                localStorage.setItem("user_saas_id", user.user_saas_id);
            }
            localStorage.setItem("worker", JSON.stringify(worker));
            localStorage.setItem("saasConfig", JSON.stringify(saasConfig));
            localStorage.setItem("pcConfig", banner);
            if (Object.keys(shopUser).length) {
                localStorage.setItem("shopUser", JSON.stringify(shopUser));
                localStorage.setItem("company", shopUser.company_id);
            }

            

        })
        .catch(err => {
            console.log(err);
        });
}

